from app import BASE_URL


class RechargeApi():

    def __init__(self, session):
        self.session = session
        self.get_recharge_code_url = BASE_URL + "/common/public/verifycode/{}"
        self.get_recharge_url = BASE_URL + "/trust/trust/recharge"

    # 获取充值验证码接口
    def get_recharge_code(self, r):
        url = self.get_recharge_code_url.format(r)
        return self.session.get(url)

    # 充值接口
    def get_recharge(self, paymentType, amount, formStr, valicode):
        param = {
            "paymentType": paymentType,
            "amount": amount,
            "formStr": formStr,
            "valicode": valicode
        }
        return self.session.post(self.get_recharge_url, data=param)
